import ProCard from '@ant-design/pro-card';
import TabPane from '@ant-design/pro-card/lib/components/TabPane';
import { Tabs } from 'antd';
// import { Link } from 'umi';
import './index.less';
import AnnouncementList from './AnnouncementList';
import { KeepAlive } from 'umi'

/* const walk = (node, callback) => {
  callback(node);
  if (node.children && node.children.length !== 0) {
    node.children.forEach((n) => {
      walk(n, callback);
    });
  }
};
 */
/* const category = {
  id: '金融公告',
  children: [
    {
      id: '重大事件',
      children: [
        {
          id: '重大合同',
        },
        {
          id: '一般投资项目',
          style: {
            lable: {
              value: '一般投资项目',
            },
          },
        },
        {
          id: '股权激励',
          style: {
            lable: {
              value: '股权激励',
            },
          },
        },
      ],
    },
    {
      id: '财务报告',
      children: [
        {
          id: '定期报告',
        },
        {
          id: '利润分配',
        },
        {
          id: '业绩报告',
        },
      ],
    },
    {
      id: '融资公告',
      children: [
        {
          id: '增发',
        },
        {
          id: '新股发行',
        },
        {
          id: '配股',
        },
      ],
    },
    {
      id: '风险提示',
      children: [
        {
          id: '股票交易异常',
        },
        {
          id: '终止上市风险',
        },
        {
          id: '月度经营状况',
        },
      ],
    },
    {
      id: '资产变动',
      children: [
        {
          id: '要约收购',
        },
        {
          id: '吸收合并',
        },
        {
          id: '回购',
        },
      ],
    },
    {
      id: '信息变更',
      children: [
        {
          id: '高管任职变动',
        },
        {
          id: '公司章程修订',
        },
        {
          id: '审计机构变更',
        },
      ],
    },
  ],
}; */

const styleGroup = [
  {
    id: '重大事件',
    className: 'tab',
    centered: true,
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '重大合同',
        subid: '重大合同',
      },
      {
        id: '一般投资项目',
        subid: '一般投资项目',
      },
      {
        id: '股权激励',
        subid: '股权激励',
      },
    ],
  },
  {
    id: '财务报告',
    centered: true,
    className: 'tab',
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '定期报告',
        subid: '一季度财务报告',
      },
      {
        id: '利润分配',
        subid: '配股',
      },
      {
        id: '业绩报告',
        subid: '年度报告',
      },
    ],
  },
  {
    id: '融资公告',
    centered: true,
    className: 'tab',
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '增发',
        subid: '增发上市公告',
      },
      {
        id: '新股发行',
        subid: '网上发行公告',
      },
      {
        id: '配股',
        subid: '配股',
      },
    ],
  },
  {
    id: '风险提示',
    centered: true,
    className: 'tab',
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '股票交易异常',
        subid: '风险提示相关',
      },
      {
        id: '终止上市风险',
        subid: '终止上市风险提示',
      },
      {
        id: '月度经营状况',
        subid: '月度经营情况',
      },
    ],
  },
  {
    id: '资产变动',
    centered: true,
    className: 'tab',
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '要约收购',
        subid: '要约收购',
      },
      {
        id: '吸收合并',
        subid: '吸收合并',
      },
      {
        id: '回购',
        subid: '回购公告',
      },
    ],
  },
  {
    id: '信息变更',
    centered: true,
    className: 'tab',
    style: {
      marginTop: '-1.5rem',
    },
    children: [
      {
        id: '高管任职变动',
        subid: '高管人员任职变动',
      },
      {
        id: '公司章程修订',
        subid: '公司章程修订',
      },
      {
        id: '审计机构变更',
        subid: '审计机构变更',
      },
    ],
  },
];
const Announcement = () => {
  return (
    <ProCard ghost direction="column">
      <ProCard
        style={{
          position: 'relative',
          borderRadius: '8px',
          marginTop: '-1.25em',
        }}
        size="small"
      >
        <div
          style={{
            fontWeight: '700',
            fontSize: '18px',
            position: 'absolute',
            left: '25px',
            top: '20px',
          }}
        >
          公告数据汇聚
        </div>
        <KeepAlive>
          <Tabs centered="true">
            {styleGroup.map(function (item) {
              return (
                <TabPane tab={item.id} key={item.id} className={item.className}>
                  <Tabs centered={item.centered} style={item.style}>
                    {item.children.map(function (item1) {
                      return (
                        <TabPane tab={item1.id} key={item1.id}>
                          <AnnouncementList cate={item1.subid}></AnnouncementList>
                        </TabPane>
                      );
                    })}
                  </Tabs>
                </TabPane>
              );
            })}
            ;
          </Tabs>
        </KeepAlive>
      </ProCard>
    </ProCard>
  );
};

export default Announcement;
